import axios from 'axios'
import Vue from 'vue'
import store from '../vuex/store';
axios.defaults.withCredentials = true
axios.defaults.headers = {
    'Content-Type': 'application/x-www-form-urlencoded'
};
var api = '';
//  添加请求拦截器
axios.interceptors.request.use(config => {
    config.headers.common = {
        'Content-Type': "application/x-www-form-urlencoded",
        'Access-Control-Allow-Origin': '*',
        'Access-Control-Allow-Headers': 'X-Requested-With,Content-Type',
        'Access-Control-Allow-Methods': 'PUT,POST,GET,DELETE,OPTIONS',
    };
    // 在发送请求之前做些什么
    return config;
    // 对请求错误做些什么
}, function(error) {

    return Promise.reject(error);
});
// 添加响应拦截器
axios.interceptors.response.use(response => { // 对响应数据做点什么    
    return response;
}, function(error) { // 对响应错误做点什么 　　
    return Promise.reject(error);
});

//登录
export const getUserInfo = (params) => {
    return axios.get(api + '../../static/mock.json', params);
};
//登出 
export const logout = (params) => {
    return axios.post(api + '/loginout.do', params);
};